 import * as type from './type'
 import state from './state'
 import _ from 'lodash'

 const reducer = ( proviousState=state,action ) => {

    let newState = _.cloneDeep( proviousState ) //深拷贝
   switch (action.type) {
      case type.GETBARLISTS:
            newState.bar_lists = action.payload
         break;
      case type.GETHOMELISTS:
            newState.home_list = action.payload
         break;
      case type.GETMOREHOMELISTS :
            newState.home_list.push( ...action.payload) 
         break;     
      case type.GETMONANDBABYBANNER :
            newState.mon_and_baby_banner = action.payload
         break;
      case type.GETMONANDBABYLISTS :
            newState.mon_and_baby_lists = action.payload
         break;
      case type.GETPOPLISTS : 
            newState.pop_lists = action.payload 
         break;
      case type.GETMOREPOPLISTS :
            newState.pop_lists.push( ...action.payload)
         break;
      case  type.GETSORTDETAILLISTS :
            newState.sort_detail = action.payload
         break;
      case type.GETINDEXDETAILISTS :
            newState.index_detail = action.payload
         break;      
      case type.GETINDEXDETAILPRICE :
            newState.index_detali_price = action.payload;
         break;      
      case type.GETLUXURYBANNER:
            newState.luxury_banner = action.payload 
            break; 
      case type.GETLUXURYLIST:
            newState.luxury_list = action.payload 
            break; 
      case type.GETBABYDETAILLIST:
            newState.baby_detail_list = action.payload 
            break; 
      case type.GETMORELUXURY :
            newState.luxury_list.push( ...action.payload)
            break;
      case type.CHANGERTITLE :
            newState.title = action.payload
            break;
      case type.ADDSHOP :
            newState.shop_car_status = action.payload
            break;
      case type.GETSHOPCARLISTS :
           newState.shop_car_lists = action.payload
           break;      
      default:
           break;
   }


    return newState
 }

 export default reducer

 